package com.chenjun.core.service.sys.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.chenjun.core.dao.generator.entity.SysArea;
import com.chenjun.core.dao.generator.mapper.SysAreaMapper;
import com.chenjun.core.dao.module.SysAreaRelationMapper;
import com.chenjun.core.service.sys.SysAreaUtilSerice;
import com.chenjun.core.vo.sys.AreaSimpleMo;

@Service("sysAreaUtilSerice")
@Transactional
public class SysAreaUtilSericeImpl implements SysAreaUtilSerice {
	@Autowired
	private SysAreaRelationMapper sysAreaRelationMapper;
	@Autowired
	private SysAreaMapper sysAreaMapper;

	@Override
	public Map<Object, Object> getAll(String id) {
		Map<Object, Object> map = new HashMap<Object, Object>();

		SysArea area3 = sysAreaMapper.selectByPrimaryKey(id);
		map.put("area3Id", area3.getId());
		SysArea area2 = sysAreaMapper.selectByPrimaryKey(area3.getParentId());
		map.put("area2Id", area2.getId());
		SysArea area1 = sysAreaMapper.selectByPrimaryKey(area2.getParentId());
		map.put("area1Id", area1.getId());
		return map;
	}

	@Override
	public List<AreaSimpleMo> getAreaByFid(String id) {
		return sysAreaRelationMapper.selectAreaByFid(id);
	}

}
